# Maintainer:
# Contributor: Jan de Groot <jgc@archlinux.org>
# Contributor: William Rea <sillywilly@gmail.com>

pkgname=wv
pkgver=1.2.9
pkgrel=6
pkgdesc="MSWord library that can load and parse Word 2000, 97, 95 and 6 file formats"
arch=(x86_64)
url="https://sourceforge.net/projects/wvware"
license=(GPL2)
depends=(
  glib2
  glibc
  libgsf
  libxml2
  sh
  zlib
)
provides=(libwv-1.2.so)
source=(
  http://www.abisource.com/downloads/$pkgname/$pkgver/$pkgname-$pkgver.tar.gz
  $pkgname-1.2.9-format_security.patch
)
sha512sums=('ae5c762012595ce8922bfda8749ad3e9cb055edab30152c3a5feaaf3ca6601f357d1e301b179e9a5860cd99452dd6e63e5f44f5bcc12f8db148bdd334e0200a5'
            '99fef3bec0f129ae2d138c50d1e3e9288d5309db87a72d9b1970d1d230e20be3469b423f0b74c5083a0a5cdca8fed0b2ca32ec1fefdca22f213e4a02a6bbd405')
b2sums=('6a6aa6b5f87a934c703c8a74d85af3d7aa84dcd2bc613a3af7fb8d69a9339e71ba2618ae8f725b90c3fe0b0199f4b224bdb32a50c2b6b6614f84b6a14437633f'
        '18641a15c75a32250012771bd8ca8b0739f503ef8d1d2eebe23f2d378996aa3f6e2f0cfa72f8077add3db33f8ece86c57e80cc5b868719472b45ba1bed10a7d0')

prepare() {
  patch -Np1 -d $pkgname-$pkgver -i ../$pkgname-1.2.9-format_security.patch
}

build() {
  local configure_options=(
    --prefix=/usr
    --mandir=/usr/share/man
    --disable-static
  )
  cd $pkgname-$pkgver

  ./configure "${configure_options[@]}"
  # prevent libtool from overlinking
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  make DESTDIR="$pkgdir" install -C $pkgname-$pkgver
}
